Context switching in a scheduler

ABSTRACT

A scheduler in a process of a computer system detects a task with an associated execution context that has not been previously invoked by the scheduler. The scheduler executes the task on a processing resource without performing a context switch if the processing resource executed a previous task to completion. The scheduler stores the execution context originally associated with the task for later use.

BACKGROUND

Processes executed in a computer system may include execution contextschedulers that schedule tasks of processes for execution in thecomputer system. A scheduler may create execution contexts (e.g.,threads, fibers, or child processes) in order to execute tasks onprocessing resources. When a task blocks or is interrupted duringexecution on a processing resource, the state of the execution contexton the processing resource is saved to allow the execution context tolater be restored when the task resumes. The processing resource maythen switch to a different execution context to continue executingtasks.

The process of switching execution contexts on a processing resourcegenerally involves a significant amount of overhead. The process ofsaving the state of an execution context is time consuming and typicallyprevents other tasks from being executed on a processing resource whilethe state is being saved.

SUMMARY

This summary is provided to introduce a selection of concepts in asimplified form that are further described below in the DetailedDescription. This summary is not intended to identify key features oressential features of the claimed subject matter, nor is it intended tobe used to limit the scope of the claimed subject matter.

A scheduler in a process of a computer system operates to minimizecontext switching between execution contexts. The scheduler detects atask with an associated execution context that has not been previouslyinvoked by the scheduler. The scheduler executes the task on aprocessing resource without performing a context switch if theprocessing resource executed a most recent previous task to completion.The scheduler stores the execution context originally associated withthe task for later use.

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings are included to provide a furtherunderstanding of embodiments and are incorporated in and constitute apart of this specification. The drawings illustrate embodiments andtogether with the description serve to explain principles ofembodiments. Other embodiments and many of the intended advantages ofembodiments will be readily appreciated as they become better understoodby reference to the following detailed description. The elements of thedrawings are not necessarily to scale relative to each other. Likereference numerals designate corresponding similar parts.

FIG. 1 is a block diagram illustrating an embodiment of a schedulerconfigured to elide an execution context switch.

FIG. 2 is a block diagram illustrating an embodiment of a schedulinggroup for use in a scheduler.

FIG. 3 is a flow chart illustrating an embodiment of a method foreliding an execution context switch.

FIGS. 4A-4C are block diagrams illustrating embodiments of executioncontext switching.

FIGS. 5A-5C are block diagrams illustrating embodiments of eliding anexecution context switch.

FIG. 6 is a block diagram illustrating an embodiment of a computersystem configured to implement a runtime environment including ascheduler configured to elide an execution context switch.

DETAILED DESCRIPTION

In the following Detailed Description, reference is made to theaccompanying drawings, which form a part hereof, and in which is shown,by way of illustration, specific embodiments in which the invention maybe practiced. In this regard, directional terminology, such as “top,”“bottom,” “front,” “back,” “leading,” “trailing,” etc., is used withreference to the orientation of the Figure(s) being described. Becausecomponents of embodiments can be positioned in a number of differentorientations, the directional terminology is used for purposes ofillustration and is in no way limiting. It is to be understood thatother embodiments may be utilized and structural or logical changes maybe made without departing from the scope of the present invention. Thefollowing detailed description, therefore, is not to be taken in alimiting sense, and the scope of the present invention is defined by theappended claims.

It is to be understood that the features of the various exemplaryembodiments described herein may be combined with each other, unlessspecifically noted otherwise.

FIG. 1 is a block diagram illustrating an embodiment of a scheduler 22configured to elide an execution context switch in a process 12 of aruntime environment 10.

Runtime environment 10 represents a runtime mode of operation in acomputer system, such as a computer system 100 shown in FIG. 6 anddescribed in additional detail below, where the computer system isexecuting instructions. The computer system generates runtimeenvironment 10 from a runtime platform such as a runtime platform 122shown in FIG. 6 and described in additional detail below.

Runtime environment 10 includes an least one invoked process 12, aresource management layer 14, and a set of hardware threads 16(1)-16(M),where M is an integer that is greater than or equal to one and denotesthe Mth hardware thread 16(M). Runtime environment 10 allows tasks fromprocess 12 to be executed, along with tasks from any other processesthat co-exist with process 12 (not shown), using resource managementlayer 14 and hardware threads 16(1)-16(M). Runtime environment 10operates in conjunction resource management layer 14 to allow process 12to obtain processor and other resources of the computer system (e.g.,hardware threads 16(1)-16(M)).

Runtime environment 10 includes a scheduler function that generatesscheduler 22. In one embodiment, the scheduler function is implementedas a scheduler application programming interface (API). In otherembodiments, the scheduler function may be implemented using othersuitable programming constructs. When invoked, the scheduler functioncreates scheduler 22 in process 12 where scheduler 22 operates toschedule tasks of process 12 for execution by one or more hardwarethreads 16(1)-16(M). Runtime environment 10 may exploit fine grainedconcurrency that application or library developers express in theirprograms (e.g., process 12) using accompanying tools that are aware ofthe facilities that the scheduler function provides.

Process 12 includes an allocation of processing and other resources thathosts one or more execution contexts (viz., threads). Process 12 obtainsaccess to the processing and other resources in the computer system(e.g., hardware threads 16(1)-16(M)) from resource management layer 14.Process 12 causes tasks to be executed using the processing and otherresources.

Process 12 generates work in tasks of variable length where each task isassociated with an execution context in scheduler 22. Each task includesa sequence of instructions that perform a unit of work when executed bythe computer system. Each execution context forms a thread that executesassociated tasks on allocated processing resources. Each executioncontext includes program state and machine state information. Executioncontexts may terminate when there are no more tasks left to execute. Foreach task, runtime environment 10 and/or process 12 either assign thetask to scheduler 22 to be scheduled for execution or otherwise causethe task to be executed without using scheduler 22.

Process 12 may be configured to operate in a computer system based onany suitable execution model, such as a stack model or an interpretermodel, and may represent any suitable type of code, such as anapplication, a library function, or an operating system service. Process12 has a program state and machine state associated with a set ofallocated resources that include a defined memory address space. Process12 executes autonomously or substantially autonomously from anyco-existing processes in runtime environment 10. Accordingly, process 12does not adversely alter the program state of co-existing processes orthe machine state of any resources allocated to co-existing processes.Similarly, co-existing processes do not adversely alter the programstate of process 12 or the machine state of any resources allocated toprocess 12.

Resource management layer 14 allocates processing resources to process12 by assigning one or more hardware threads 16 to process 12. Resourcemanagement layer 14 exists separately from an operating system of thecomputer system (not shown in FIG. 1) in the embodiment of FIG. 1. Inother embodiments, resource management layer 14 or some or all of thefunctions thereof may be included in the operating system.

Hardware threads 16 reside in execution cores of a set or one or moreprocessor packages (e.g., processor packages 102 shown in FIG. 6 anddescribed in additional detail below) of the computer system. Eachhardware thread 16 is configured to execute instructions independentlyor substantially independently from the other execution cores andincludes a machine state. Hardware threads 16 may be included in asingle processor package or may be distributed across multiple processorpackages. Each execution core in a processor package may include one ormore hardware threads 16.

Process 12 implicitly or explicitly causes scheduler 22 to be createdvia the scheduler function provided by runtime environment 10. Schedulerinstance 22 may be implicitly created when process 12 uses APIsavailable in the computer system or programming language features. Inresponse to the API or programming language features, runtimeenvironment 10 creates scheduler 22 with a default policy. To explicitlycreate a scheduler 22, process 12 may invoke the scheduler functionprovided by runtime environment 10 and specify one or more policies forscheduler 22.

Scheduler 22 interacts with resource management layer 14 to negotiateprocessing and other resources of the computer system in a manner thatis transparent to process 12. Resource management layer 14 allocateshardware threads 16 to scheduler 22 based on supply and demand and anypolicies of scheduler 22.

In the embodiment shown in FIG. 1, scheduler 22 manages the processingresources by creating virtual processors 32 that form an abstraction ofunderlying hardware threads 16. Scheduler 22 includes a set of virtualprocessors 32(1)-32(N) where N is an integer greater than or equal toone and denotes the Nth virtual processor 32(N). Scheduler 22multiplexes virtual processors 32 onto hardware threads 16 by mappingeach virtual processor 32 to a hardware thread 16. Scheduler 22 may mapmore than one virtual processor 32 onto a particular hardware thread 16but maps only one hardware thread 16 to each virtual processor 32. Inother embodiments, scheduler 22 manages processing resources in othersuitable ways to cause instructions of process 12 to be executed byhardware threads 16.

The set of execution contexts in scheduler 22 includes a set ofexecution contexts 34(1)-34(N) with respective, associated tasks36(1)-36(N) that are being executed by respective virtual processors32(1)-32(N) and, at any point during the execution of process 12, a setof zero or more execution contexts 38. Each execution context 34 and 38includes state information that indicates whether an execution context34 or 38 is executing, runnable (e.g., in response to becoming unblockedor added to scheduler 22), or blocked. Execution contexts 34 that areexecuting have been attached to a virtual processor 32 and are currentlyexecuting. Execution contexts 38 that are runnable include an associatedtask 40 and are ready to be executed by an available virtual processor32. Execution contexts 38 that are blocked also include an associatedtask 40 and are waiting for data or a message that is being generated byanother execution context 34 or will be generated by another executioncontext 38.

Each execution context 34 executing on a virtual processor 32 maygenerate, in the course of its execution, additional tasks 42, which areorganized in any suitable way (e.g., added to work queues (not shown inFIG. 1)). Work may be created by using either application programminginterfaces (APIs) provided by runtime environment 10 or programminglanguage features and corresponding tools in one embodiment. Whenprocessing resources are available to scheduler 22, tasks are assignedto execution contexts 34 or 38 that execute them to completion onvirtual processors 32 before picking up new tasks. An execution context34 executing on a virtual processor 32 may also unblock other executioncontexts 38 by generating data or a message that will be used by otherexecution contexts 38.

Each task in scheduler 22 may be realized (e.g., realized tasks 36 and40), which indicates that an execution context 34 or 38 has been or willbe attached to the task and the task is ready to execute. Realized taskstypically include unblocked execution contexts and scheduled agents. Atask that is not realized is termed unrealized. Unrealized tasks (e.g.,tasks 42) may be created as child tasks generated by the execution ofparent tasks and may be generated by parallel constructs (e.g.,parallel, parallel for, begin, and finish). Scheduler 22 may beorganized into a synchronized collection (e.g., a stack and/or a queue)for logically independent tasks with execution contexts (i.e., realizedtasks) along with a list of workstealing queues for dependent tasks(i.e., unrealized tasks) as illustrated in the embodiment of FIG. 2described below.

Upon completion, blocking, or other interruption (e.g., explicityielding or forced preemption) of an execution context 34 running on avirtual processor 32, the virtual processor 32 becomes available toexecute another realized task 40 or unrealized task 42. Scheduler 22searches for a runnable execution context 38 or an unrealized task 42 toattach to the available virtual processor 32 for execution in anysuitable way. For example, scheduler 22 may first search for a runnableexecution context 38 to execute before searching for an unrealized task42 to execute. Scheduler 22 continues attaching execution contexts 38 toavailable virtual processors 32 for execution until all executioncontexts 38 of scheduler 22 have been executed.

In one embodiment, process 12 organizes tasks into one or more schedulegroups 50 and presents schedule groups 50 to scheduler 22. FIG. 2 is ablock diagram illustrating an embodiment of a schedule group 50 for usein scheduler 22.

Schedule group 50 includes a runnables collection 52, a realized taskcollection 53, a work collection 54, and a set of zero or moreworkstealing queues 56. Runnables collection 52 contains a list ofunblocked execution contexts 38. Scheduler 22 adds an execution context38 to runnables collections 52 when an execution context becomesunblocked. Realized task collection 53 contains a list of realized tasks40 (e.g., unstarted agents) that may or may not have associatedexecution contexts 38. Scheduler 22 adds a realized task to realizedtask collection 53 when a new runnable task is presented to scheduler 22by process 12. Work queue 54 contains a list of workstealing queues 56as indicated by an arrow 58 and tracks the execution contexts 34 thatare executing tasks from the workstealing queues 56. Each workstealingqueue 56 includes one or more unrealized tasks 42.

Using the embodiment of FIG. 2, scheduler 22 may first search forunblocked execution contexts 38 in the runnables collection 52 of allschedule groups 50 in scheduler 22. Scheduler 22 may then search forrealized tasks in the realized task collection 53 of all schedule groups50 in scheduler 22 before searching for unrealized tasks in theworkstealing queues 56 of the schedule groups 50.

In one embodiment, a virtual processor 32 that becomes available mayattempt to locate a runnable execution context 38 in the runnablescollection 52 in the schedule group 50 from which the available virtualprocessor 32 most recently obtained a runnable execution context 38(i.e., the current schedule group 50). The available virtual processor32 may then attempt to locate a runnable execution context 38 in therunnables collections 52 in the remaining schedule groups 50 ofscheduler 22 in a round-robin or other suitable order. If no runnableexecution context 38 is found, then the available virtual processor 32may then attempt to locate an unrealized task 42 in the workstealingqueues 56 of the current schedule group 50 before searching theworkstealing queues 56 in the remaining schedule groups 50 of scheduler22 in a round-robin or other suitable order.

Prior to executing tasks, scheduler 22 obtains execution contexts 34 and38 from runtime environment 10 or an operating system (e.g., OS 120 ofFIG. 6). Available virtual processors 32 locate and execute executioncontexts 34 to begin executing tasks. Virtual processors 32 becomeavailable again in response to an execution context 34 completing,blocking, or otherwise being interrupted. When virtual processors 32become available, virtual processors 32 switch to a runnable executioncontext 38 or execute a next task 40 or 42 as a continuation on acurrent execution context 34 if the previous task 36 executed by thecurrent execution context 34 completed.

Scheduler 22 operates to minimize context switching between executioncontexts 34 and 38. When a virtual processor 32 executes a task 36 tocompletion (i.e., task 36 does not block and is not otherwiseinterrupted) and becomes available, the available virtual processor 32attempts to execute a next task 40 or 42 as a continuation on a currentexecution context 34. If the next task 40 is possibly already associatedwith an execution context 38, the available virtual processor 32executes the task 40 as a continuation on a current execution context 34if the task 40 has not been previously invoked by scheduler 22. Theavailable virtual processor 32 executes the task 40 without switching tothe execution context 38 associated with the task 40. Scheduler 22stores the execution context 38 for later use by the same or anothervirtual processor 32. By doing so, scheduler 22 and the availablevirtual processor 32 elide a context switch in executing an uninvokedtask 40 originally associated with an execution context 38.

FIG. 3 is a flow chart illustrating an embodiment of a method foreliding an execution context switch. The method of FIG. 3, as performedby scheduler 22, will be described with reference to the embodiments ofFIGS. 4A-4C and FIGS. 5A-5C. FIGS. 4A-4C are block diagrams illustratingembodiments of execution context switching. FIGS. 5A-5C are blockdiagrams illustrating embodiments of eliding an execution contextswitch.

In FIG. 3, a determination is made in scheduler 22 as to whether a task36 executes to completion on a processing resource as indicated in ablock 62. The processing resource detects whether the task 36 executedto completion without blocking or being interrupted. If the task did notexecute to completion (i.e., the task blocked or was interrupted), thenthe processing resource switches to a different execution context 38 asindicated in a block 64. The processing resource causes the blocked orinterrupted execution context 34 to be stored and begins executing anext task 40 or 42 with a new execution context 38 in scheduler 22 ifone is available. If the previous task 36 executed to completion, thenthe processing resource may be able to execute the next task 40 or 42 asa continuation on execution context 34.

In the example of FIGS. 4A-4C, virtual processor 32(1) has becomeavailable subsequent to executing a task 36(1) (not shown in FIG. 4A)with an execution context 34(1) that blocked or was interrupted. Virtualprocessor 32(1) is searching for a next task 40 or 42 to execute asindicated by an arrow 92. Virtual processors 32(2)-32(4) are executingrespective tasks 36(2)-36(4) with respective execution contexts34(2)-34(4).

If task 36(1) blocked or was interrupting while executing on virtualprocessor 32(1), then virtual processor 32(1) performs a context switchfrom execution context 34(1) to execution context 38(1) and executes anext task 40(1) with execution context 38(1) as shown in FIG. 4B.Virtual processor 32(1) causes the blocked or interrupted executioncontext 34(1) to be stored.

If task 40(1) blocks or is interrupted while executing on virtualprocessor 32(1), virtual processor 32(1) causes execution context 38(1)to be stored and searches for another execution context 34 or 38 with anassociated task 40 or 42 to execute. When virtual processor 32(1)searches for a next task 40 or 42 to execute, virtual processor 32(1)may execute a task 40(2) associated with execution context 34(1) asshown in the example of FIG. 4C. If task 40(1) completes, virtualprocessor 32(1) may repeat the function of block 62.

Referring back to FIG. 3, if the task 36 executed to completion, then adetermination is made by scheduler 22 as to whether the next task toexecute is a task 40 that has been previously invoked by scheduler 22indicated in a block 66. If the next task has been previously invoked byscheduler 22, then the processing resource switches to a differentexecution context 38 to execute the task as indicated in block 64.

If the next task 40 or 42 has not been previously invoked by scheduler22, then a determination is made by scheduler 22 as to whether the nexttask 40 or 42 is associated with an execution context 38 as indicated ina block 68. If the next task 40 or 42 has not been associated with anexecution context 38, then the processing resource executes the nexttask 40 or 42 with a current execution context 34 as indicated in ablock 70. The processing resource executes the next task 40 or 42 as acontinuation on the current execution context 34.

In the example of FIG. 5A, virtual processor 32(1) has become availablesubsequent to executing task 36(1) (not shown in FIG. 5A) to completionwith execution context 34(1). Virtual processor 32(1) is searching for anext task 40 or 42 to execute as indicated by an arrow 96. Virtualprocessors 32(2)-32(4) are executing respective tasks 36(2)-36(4) withrespective execution contexts 34(2)-34(4).

Because task 36(1) completed, virtual processor 32(1) may search for anext task 40 or 42 to execute as a continuation on execution context34(1). Virtual processor 32(1) may also perform a context switch fromexecution context 34(1) to execution context 38(1), execute a next task40(1) with execution context 38(1), and cause execution context 34(1) tobe stored as described above with reference to FIG. 4B.

Referring back to FIG. 3, if a next task 40 has an associated executioncontext 38 and has not been previously invoked by scheduler 22, then theprocessing resource executes the uninvoked task 40 with a currentexecution context 34 as indicated in a block 72. Because the next task40 has not been previously invoked by scheduler 22, the task 40 may beexecuted without performing a context switch to the execution context 38associated with the task 40. Instead, the processing resource executesthe task 40 as a continuation on the current execution context 34.

Referring to FIGS. 5A-5B, virtual processor 32(1) identifies a next task40(1) to execute where task 40(1) is associated with execution context38(1). Virtual processor 32(1) detects that task 40(1) has not beenpreviously invoked by scheduler 22. Because task 36(1) executed tocompletion, virtual processor 32(1) elides a context switch fromexecution context 34(1) to execution context 38(1) and executes task40(1) with execution context 34(1) as shown in FIG. 5B. Virtualprocessor 32(1) executes task 40(1) as a continuation on executioncontext 34(1) and does not switch to execution context 38(1).

Scheduler 22 stores the original execution context associated with thetask for later use as indicated in a block 74. As shown in FIG. 5B,virtual processor 32(1) causes execution context 38(1) to be stored inresponse to executing task 40(1) with execution context 34(1).

A determination is made by scheduler 22 as to whether as the task 40blocks, is interrupted, or completes as indicated in a block 76.Subsequent to the next task 40 blocking, being interrupted, orcompleting, the processing resource repeats the function of block 62.

In the example of FIG. 5C, task 40(1) blocks or is interrupted whileexecuting with execution context 34(1) on virtual processor 32(1).Virtual processor 32(1) performs a context switch from execution context34(1) to execution context 38(1) (i.e., the execution context originallyassociated with task 40(1)) to execute a task 40(3) associated withexecution context 38(1).

In other examples, another virtual processor 32 may switch to executioncontext 38(1) (i.e., the execution context originally associated withtask 40(1)) and execute subsequent tasks 40 and/or 42 associated withexecution context 38(1).

FIG. 6 is a block diagram illustrating an embodiment of computer system100 which is configured to implement runtime environment 10 includingscheduler 22 configured to elide an execution context switch asdescribed above.

Computer system 100 includes one or more processor packages 102, amemory system 104, zero or more input/output devices 106, zero or moredisplay devices 108, zero or more peripheral devices 110, and zero ormore network devices 112. Processor packages 102, memory system 104,input/output devices 106, display devices 108, peripheral devices 110,and network devices 112 communicate using a set of interconnections 114that includes any suitable type, number, and configuration ofcontrollers, buses, interfaces, and/or other wired or wirelessconnections.

Computer system 100 represents any suitable processing device configuredfor a general purpose or a specific purpose. Examples of computer system100 include a server, a personal computer, a laptop computer, a tabletcomputer, a personal digital assistant (PDA), a mobile telephone, and anaudio/video device. The components of computer system 100 (i.e.,processor packages 102, memory system 104, input/output devices 106,display devices 108, peripheral devices 110, network devices 112, andinterconnections 114) may be contained in a common housing (not shown)or in any suitable number of separate housings (not shown).

Processor packages 102 include hardware threads 16(1)-16(M). Eachhardware thread 16 in processor packages 102 is configured to access andexecute instructions stored in memory system 104. The instructions mayinclude a basic input output system (BIOS) or firmware (not shown), anoperating system (OS) 120, a runtime platform 122, applications 124, andresource management layer 14 (also shown in FIG. 1). Each hardwarethread 16 may execute the instructions in conjunction with or inresponse to information received from input/output devices 106, displaydevices 108, peripheral devices 110, and/or network devices 112.

Computer system 100 boots and executes OS 120. OS 120 includesinstructions executable by hardware threads 16 to manage the componentsof computer system 100 and provide a set of functions that allowapplications 124 to access and use the components. In one embodiment, OS120 is the Windows operating system. In other embodiments, OS 120 isanother operating system suitable for use with computer system 100.

Resource management layer 14 includes instructions that are executablein conjunction with OS 120 to allocate resources of computer system 100including hardware threads 16 as described above with reference toFIG. 1. Resource management layer 14 may be included in computer system100 as a library of functions available to one or more applications 124or as an integrated part of OS 120.

Runtime platform 122 includes instructions that are executable inconjunction with OS 120 and resource management layer 14 to generateruntime environment 10 and provide runtime functions to applications124. These runtime functions include a scheduler function as describedin additional detail above with reference to FIG. 1. The runtimefunctions may be included in computer system 100 as part of anapplication 124, as a library of functions available to one or moreapplications 124, or as an integrated part of OS 120 and/or resourcemanagement layer 14.

Each application 124 includes instructions that are executable inconjunction with OS 120, resource management layer 14, and/or runtimeplatform 122 to cause desired operations to be performed by computersystem 100. Each application 124 represents one or more processes, suchas process 12 as described above, that may execute with scheduler 22 asprovided by runtime platform 122.

Memory system 104 includes any suitable type, number, and configurationof volatile or non-volatile storage devices configured to storeinstructions and data. The storage devices of memory system 104represent computer readable storage media that store computer-executableinstructions including OS 120, resource management layer 14, runtimeplatform 122, and applications 124. The instructions are executable bycomputer system to perform the functions and methods of OS 120, resourcemanagement layer 14, runtime platform 122, and applications 124described herein. Examples of storage devices in memory system 104include hard disk drives, random access memory (RAM), read only memory(ROM), flash memory drives and cards, and magnetic and optical disks.

Memory system 104 stores instructions and data received from processorpackages 102, input/output devices 106, display devices 108, peripheraldevices 110, and network devices 112. Memory system 104 provides storedinstructions and data to processor packages 102, input/output devices106, display devices 108, peripheral devices 110, and network devices112.

Input/output devices 106 include any suitable type, number, andconfiguration of input/output devices configured to input instructionsor data from a user to computer system 100 and output instructions ordata from computer system 100 to the user. Examples of input/outputdevices 106 include a keyboard, a mouse, a touchpad, a touchscreen,buttons, dials, knobs, and switches.

Display devices 108 include any suitable type, number, and configurationof display devices configured to output textual and/or graphicalinformation to a user of computer system 100. Examples of displaydevices 108 include a monitor, a display screen, and a projector.

Peripheral devices 110 include any suitable type, number, andconfiguration of peripheral devices configured to operate with one ormore other components in computer system 100 to perform general orspecific processing functions.

Network devices 112 include any suitable type, number, and configurationof network devices configured to allow computer system 100 tocommunicate across one or more networks (not shown). Network devices 112may operate according to any suitable networking protocol and/orconfiguration to allow information to be transmitted by computer system100 to a network or received by computer system 100 from a network.

Although specific embodiments have been illustrated and describedherein, it will be appreciated by those of ordinary skill in the artthat a variety of alternate and/or equivalent implementations may besubstituted for the specific embodiments shown and described withoutdeparting from the scope of the present invention. This application isintended to cover any adaptations or variations of the specificembodiments discussed herein. Therefore, it is intended that thisinvention be limited only by the claims and the equivalents thereof.

1. A method performed by a scheduler of a process executing on acomputer system, the method comprising: executing a first taskassociated with a first execution context to completion on a firstprocessing resource allocated to the scheduler; and executing a secondtask associated with a second execution context with the first executioncontext on the first processing resource in response to the second tasknot being invoked previously by the scheduler.
 2. The method of claim 1further comprising: executing the second task with the second executioncontext on the first processing resource in response to the second taskbeing invoked previously by the scheduler.
 3. The method of claim 2further comprising: performing a context switch from the first executioncontext to the second execution context on the first processing resourcein response to the second task being invoked previously by thescheduler.
 4. The method of claim 1 further comprising: storing thesecond execution context in response to executing the second task withthe first execution context.
 5. The method of claim 1 furthercomprising: switching to the second execution context on the firstprocessing resource to execute a third task associated with the secondexecution context and previously invoked by the scheduler subsequent toexecuting the second task with the first execution context.
 6. Themethod of claim 1 further comprising: switching to the second executioncontext on a second processing resource allocated to the scheduler toexecute a third task associated with the second execution context andpreviously invoked by the scheduler subsequent to executing the secondtask with the first execution context.
 7. The method of claim 1 furthercomprising: obtaining the first execution context from an operatingsystem prior to executing the first task.
 8. The method of claim 1wherein the first processing resource includes a virtual processor and ahardware thread.
 9. A computer readable storage medium storingcomputer-executable instructions that, when executed by a computersystem, perform a method in a scheduler in a process executing on thecomputer system, the method comprising: executing a first taskassociated with a first execution context as a continuation on a secondexecution context on a first processing resource of the scheduler inresponse to the first task being not invoked previously by thescheduler; and performing a first context switch from the secondexecution context to the first execution context on the first processingresource in response to the first task being invoked previously by thescheduler.
 10. The computer readable storage medium of claim 9, themethod further comprising: storing the first execution context inresponse to executing the first task with the second execution context.11. The computer readable storage medium of claim 10, the method furthercomprising: performing a second context switch from the second executioncontext to the first execution context on the first processing resourceto execute a second task associated with the first execution contextsubsequent to executing the first task with the second executioncontext.
 12. The computer readable storage medium of claim 10, themethod further comprising: performing a second context switch from athird execution context to the first execution context on a secondprocessing resource of the scheduler to execute a second task associatedwith the first execution context.
 13. The computer readable storagemedium of claim 9, the method further comprising: executing the firsttask with the first execution context on the first processing resourcesubsequent to performing the first context switch.
 14. The computerreadable storage medium of claim 9, the method further comprising:executing a second task associated with the second execution context tocompletion on the first processing resource prior to executing the firsttask with the second execution context.
 15. The computer readablestorage medium of claim 9, the method further comprising: performing thefirst context switch from the second execution context to the firstexecution context on the first processing resource in response to asecond task associated with the second execution context blocking orbeing interrupted.
 16. A method performed by a scheduler in a processexecuting on a computer system comprising: detecting a first taskassociated with a first execution context, wherein the first task hasnot been invoked previously by the scheduler; and executing the firsttask as a continuation on a second execution context on a firstprocessing resource of the scheduler.
 17. The method of claim 16 furthercomprising: executing the first task as the continuation on the secondexecution context on the first processing resource in response to asecond task executed by the first processing resource with the secondexecution context completing and not blocking or being interrupted. 18.The method of claim 16 further comprising: storing the first executioncontext in response to executing the first task as the continuation. 19.The method of claim 16 further comprising: performing a context switchfrom the second execution context to the first execution context on thefirst processing resource to execute a second task associated with thefirst execution context subsequent to executing the first task as thecontinuation.
 20. The method of claim 16 further comprising: performinga context switch from a third execution context to the first executioncontext on a second processing resource of the scheduler to execute asecond task associated with the first execution context.